package de.preamp.clients.java.playlist;

import javax.swing.ListModel;
import javax.swing.event.ListSelectionListener;

import de.preamp.clients.java.data.Track;

/**
 * An interface for classes representing a playlist. It extends the components
 * needed to be shown by java swing in a JList.
 * 
 * @author André Stannek
 * @version 2009-08-30
 * @see javax.swing.ListModel
 * @see javax.swing.event.ListSelectionListener
 */
public interface Playlist extends Iterable<Track>, ListSelectionListener,
	ListModel
{
    /**
     * Returns the {@link Track} next to the one the current index points to and
     * sets the index to that successor.
     * 
     * @return the next {@link Track}
     */
    Track getNextTrack();

    /**
     * Returns the {@link Track} the current index points to. This is the track
     * that should be played if this playlist is played.
     * 
     * @return the current {@link Track}
     */
    Track getCurrentTrack();

    /**
     * Returns the {@link Track} previous to the one the current index points to
     * and sets the index to that predecessor.
     * 
     * @return the previous {@link Track}
     */
    Track getPreviousTrack();

    /**
     * Adds a track at the end of the playlist.
     * 
     * @param track
     *            the track to add
     * @return true if the track was added, false else
     */
    boolean add(Track track);

    /**
     * Adds a {@link Track} at a specific index.
     * 
     * @param index
     *            the index where the track should be added
     * @param track
     *            the track to add
     */
    void add(int index, Track track);

    /**
     * removes the first {@link Track} in this playlist that equals the given
     * track and notifies all ListDataListeners.
     * 
     * @param track
     *            the track to be removed
     */
    void remove(Track track);

    /**
     * Sets the index this playlist has his focus on. Sets the last index if the
     * index is to large or the first if it is to small.
     * 
     * @param index
     *            the index
     */
    void setIndex(int index);

    /**
     * @return the name of this playlist
     */
    String getName();

    /**
     * Changes the name of this playlist.
     * 
     * @param name
     *            the new name for the playlist
     */
    void setName(String name);
}
